<%@ page language="java" contentType="text/html; charset=utf-8"%>
<html>
<head>
<%@ include file="/extjs/include/all.jsp"%>
<title>日志管理</title>
</head>
<body>
<div id="editLoggerLevel" style="width: 100%"></div>
</body>
</html>
<script>
Ext.onReady(function(){

	var levelStore = new Ext.data.JsonStore({
		url: '${pageContext.request.contextPath}/edu.ccut.saturn.manager.logger.impl::/loggerModule/ExtAction/QueryAllLoggerLevel.action',
		root: 'allLevel',
		fields: [
			{name:'key'},
			{name:'value'}
		]
	});
	levelStore.load();
	var editLogger = new Ext.FormPanel({
	    labelWidth: 75,
	    id:'editLogger',
	    frame:true,
	    title: '编辑日志信息',
	    bodyStyle:'padding:5px 5px 0',
	    width: 350,
	    defaults: {width: 230},
	    defaultType: 'textfield',
	    items: [ {
	            name: 'key',
	            id: 'key',
	            inputType:'hidden',
	            hidden:true,
	            value:'<%=request.getParameter("key")%>'
	        },{
	        	fieldLabel: '日志名称',
	            name: 'key_show',
	            id: 'key_show',
	            disabled:true,
	            value:'<%=request.getParameter("key")%>'
	        },{
	            xtype:'combo',
				fieldLabel: '日志级别',
                name: 'level_show',
                id: 'level_show',
                store: levelStore,
		        displayField:'value',
		        valueField :'key',  
		        hiddenName: 'level' ,
		        typeAhead: true,
		        mode: 'local',
		        forceSelection: true,
		        triggerAction: 'all',
		        selectOnFocus:true,
		        editable: false,
		        allowBlank:false,
	            blankText:'职位不可为空',
	            value:'<%=request.getParameter("level")%>'
	        }
	    ]
	});
					
     var win = new Ext.Window({
         layout      : 'fit',
         width       : 400,
         height      : 200,
         plain       : true,
         closable: false,
         items: [editLogger],
         buttons: [{
             text     : '确定',
             handler  : function(){
                if(editLogger.form.isValid()){
                		editLogger.form.submit({					                		
                			url: '${pageContext.request.contextPath}/edu.ccut.saturn.manager.logger.impl::/loggerModule/ExtAction/UpdateLogger.action', 
		               		success : function(form, action) {
	               				var myResult = Ext.util.JSON.decode(action.response.responseText);
               					Ext.MessageBox.show({
	               				 		title: '信息',
	                                    msg: myResult.message,
	                                    width:200,
	                                    buttons: Ext.MessageBox.OK,
	                                    fn: function(btn) {
									         window.location = '${pageContext.request.contextPath}/edu.ccut.saturn.manager.logger.impl/loggerModule/ExtPage/loggers.jsp';
									    }
                                 }); 
		                    },
                      	    failure: function(form, action) {
		                       	Ext.MessageBox.show({
		                                   title: '错误',
		                                   msg: '对不起，与后台联系发生错误！',
		                                   buttons: Ext.MessageBox.OK,
		                                   icon: Ext.MessageBox.ERROR
			                    });
	                        },
              				waitMsg:'正在修改用户信息，请稍后...'
               			});
                	}else{
                		Ext.MessageBox.alert('警告','对不起，您的信息有误！')
                	}
                }
            },{
                text     : '返回',
                handler  : function(){
                    window.history.back();
                    }
           },{
                text     : '重置',
                handler  : function(){
                    editLogger.form.reset();
                    }
           }]
       });
       win.show();
       Ext.get('level').dom.value = '<%=request.getParameter("level")%>';
});
</script>